package com.longge;

public class HIndexII {
    //citations[i] 引用次数  升序排列 后面的篇数都引用了citations[i]次以上
    public int hIndex(int[] citations) {
        int left = 0, right = citations.length, n = citations.length;
        while (left < right) {
            int mid = left + (right - left) / 2;
            if (citations[mid] > n - mid) {
                right = mid;
            } else if (citations[mid] < n - mid) {
                left = mid + 1;
            } else if (citations[mid] == n - mid) {
                return citations[mid];
            }

        }
        return n - left;

    }
}
